<?php

class PaperExpense extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ut_paper_expense';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ut_format_id, ut_exp_edition, ut_exp_count', 'required'),
			array('ut_format_id, ut_exp_edition ,ut_exp_count', 'type', 'integer'),
		);
	}

	public function scopes()
	{
		return array(
			'edition'=>array(
				'condition'=>'ut_exp_edition<=:edition',
			),
		);
	}	
	
	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'format' => array(self::BELONGS_TO, 'Format', 'ut_format_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ut_format_id' => 'Формат',
			'ut_exp_edition' => 'Тираж',
			'ut_exp_count' => 'Расход',
		);
	}

}